﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.XCMG.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PMS.XCMG.Entity
{
    /// <summary>
    /// 实收明细记录
    /// </summary>
    public partial class RealIncome : BusEntity
    {
        public RealIncome()
        {
            CreateTime = DateTime.Now;
        }

        /// <summary>
        ///  预收ID
        /// </summary>
        public string PrecollectedId { set; get; }

        /// <summary>
        /// 料位编码
        /// </summary>
        public string StoreageCode { set; get; }

        /// <summary>
        /// 实收数量
        /// </summary>
        public int Quantity { set; get; }
    }

    public partial class RealIncome : BusEntity
    {
        public Precollected Precollected { set; get; }
    }

    /// <summary>
    /// 实体配置
    /// OnModelCreating
    /// </summary>
    public class RealIncomeTypeConfig : BusEntityTypeConfig<RealIncome>, IEntityTypeConfiguration<RealIncome>
    {
        public override void Configure(EntityTypeBuilder<RealIncome> builder)
        {
            base.Configure(builder);

            #region 主外键关系
            builder.HasOne(p => p.Precollected).WithMany(p => p.RealIncomes).HasForeignKey(p => p.PrecollectedId);
            #endregion

            #region 字段属性:最大长度,是否必需,默认值
            builder.Property(p => p.PrecollectedId).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.StoreageCode).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.Quantity).IsRequired();
            #endregion

            #region 备注
            builder.HasComment("实收明细记录");
            builder.Property(p => p.PrecollectedId).HasComment("预收编号");
            builder.Property(p => p.StoreageCode).HasComment("缓存料位");
            builder.Property(p => p.Quantity).HasComment("实收数量");
            #endregion

            #region 种子数据
            #endregion
        }
    }
}
